<template>
	<view :style="{'background-color':dataobj.editable?'#f8f8f8':'#fff'}" style="height:60px; padding: 8px 18px;color:#aaa;font-size: 14px; display: flex;flex-direction: row;justify-content: space-between;">
		<view style="display: flex;align-items: center;color: #666;height:60px;">{{dataobj.colText}} 
			<view v-if="dataobj.tag_isNotEmpty" style="color: #F55C23;font-size: 6px;" class="iconfont icon-jiufuqianbaoicon14"> </view>
		</view>
		<view style="text-align: right;width: 60vw;padding-top: 4px;height:60px;" v-if="(dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly)  && dataobj.value != undefined  && isaddedit">
			<input style="height: 60px;"  maxlength="-1"  :focus="listitemindex==0" :placeholder="dataobj.placeholder"  @blur="inputblur($event)" placeholder-style="font-size:14px;" :disabled="!((dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly))" v-model="dataobj.value" />
					
		</view>
		<view style="text-align: right;width: 60vw;padding-top: 4px;height:60px;" v-else-if="dataobj.value == undefined && isaddedit">
			<input style="height: 60px;" maxlength="-1"  :placeholder="dataobj.placeholder" @blur="inputblur($event)" placeholder-style="font-size:14px;" :disabled="!((dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly))" v-model="dataobj.initial" /> 
		</view>
		<view style="text-align: right;width: 60vw;padding-top: 4px;height:60px;" v-else>
			{{dataobj.value}}
		</view>
		<!-- v-if="(dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly) && dataobj.value != undefined && isaddedit"  -->
		<view @click="navitoscan" class="iconfont icon-saomiao" style="color: #fd6137;padding: 5px; margin-right: 5px; font-size: 38px;display: flex;align-items: center;"></view>
	</view>
</template>


<script>
	var util = require("../../utils/util.js");
	export default {
		props:{
			dataobj:{
				type:Object
			},
			listblockindex:{
				type:Number
			},
			listitemindex:{
				type:Number
			},
			listindex:{
				type:Number
			},
			texttype:{
				type:String
			},
			jsonoptions:{
				type:Object
			},
			name:{
				type:String
			},
			divArea:{
				type:String
			},
			bigdatalist:{
				type:Array
			},
			pagename:{
				type:String
			},
			isaddedit:{
				type:Boolean
			},
			property:{
				type:Object
			}
		},
		
		mounted:function(){
			// #ifdef APP-PLUS
			this.stop() //pda版本要开启这句话 也要替换掉 
			// #endif
			//<input style="height: 60px;"  maxlength="-1"  :placeholder="dataobj.placeholder"  @blur="inputblur($event)" placeholder-style="font-size:14px;" :disabled="!((dataobj.tabsequence!=0) && (!dataobj.protect) && (!dataobj.edit.displayOnly))" v-model="dataobj.value" /> 
			
		},
		
		
		methods:{
			
			stop(){
			    var interval = setInterval(function(){
				    uni.hideKeyboard();//隐藏软键盘
			    },20);
				setTimeout(() => {
				    clearInterval(interval);
				},3000000);
			},
			
			
			inputblur(event){
				var that = this
				var inputvalue = event.detail.value
				var colType = that.dataobj.colType
				if((colType=='digit' || colType=='number' || colType=='long') ){
					if( inputvalue==''){
						inputvalue = 0
					}else{
						inputvalue = parseInt(inputvalue)
					}
				}
				that.dataobj.value = inputvalue
				that.dataobj.colValue = inputvalue
				that.dataobj.coldisplay = inputvalue
				that.dataobj.ismodified = true
				uni.$emit("updatelist", that.divArea, that.listindex, that.listblockindex, that.listitemindex, that.dataobj,this.pagename)
			},
			
			navitoscan(){
				var that = this
				uni.scanCode({
				     onlyFromCamera: true,
					 scanType: ['qrCode'],
				     success: function (res) {
				 		var inputvalue = res.result
						that.dataobj.value = inputvalue
						that.dataobj.colValue = inputvalue
						that.dataobj.coldisplay = inputvalue
						that.dataobj.ismodified = true
						uni.$emit("updatelist", that.divArea, that.listindex, that.listblockindex, that.listitemindex, that.dataobj, that.pagename)
					},
				})
			},
		}
	}
</script>

<style>
</style>
